#include <stdio.h>

int main()
{
    int n = 0;
    int m = 0;
    scanf("%d %d",&n,&m);
    int i = 0;
    int j = 0;
    int arr1[n];
    int arr2[m];
    for(i=0;i<n;i++)
    {
        scanf("%d ",&arr1[i]);
    }
    for(j=0;j<m;j++)
    {
        scanf("%d ",&arr2[j]);
    }
    int arr3[n+m];
    int k = 0;
    i=0;j=0;
    while(i<n&&j<m)
    {
        if(arr1[i]<arr2[j])
        {
            arr3[k++]=arr1[i++];
        }
        else
        {
            arr3[k++]=arr2[j++];
        }
    }
    if(i==n)
    {
        while(j<m)
        {
            arr3[k++]=arr2[j++];
        }
    }
    else
    {
        while(i<n)
        {
            arr3[k++]=arr1[i++];
        }
    }
    for(k=0;k<n+m;k++)
    {
        printf("%d ",arr3[k]);
    }
    return 0;
}